<style lang="scss" scoped>
    @import '../../css/training.scss';

    .tn-header{background: #fff;}

    .send-paper-require{background: #ffff;padding: 30px 0px;color:$mc2;}
    .send-paper-require label{width: 160px;text-align: center;color:$mc2;background: #fff;display: inline-block;}
    .send-paper-require .el-date-picker{width: 320px;}

    .name-box{padding: 0px 0px 25px 25px;}
    .child-list li{margin-right: 30px;font-size: 14px;color:$mc2;margin-top: 20px;float: left;}
    .blue{color: $mco;}
    .edit-icon{cursor: pointer;}

    .space-push-box{width: 100%;height:100%;display: flex;justify-content: center;align-items: center;}
    .space-push{text-align: center;}
    .space-push span{font-size: 16px;color:$mc3;margin-left: 20px;}

</style>

<style>
    .send-paper-require .el-input--small .el-input__inner{width: 145px;}
</style>

<template>
    <section>

        <section class="breadcrumb-box clearfix">
            <el-breadcrumb separator=" > " class="fl">
                <el-breadcrumb-item >培训</el-breadcrumb-item>
                <el-breadcrumb-item :to="{path: '/training/training-manage'}">培训管理</el-breadcrumb-item>
                <el-breadcrumb-item v-if="$route.meta">{{$route.meta.title}}</el-breadcrumb-item>
            </el-breadcrumb>
        </section>

        <section v-if="step == 2" class="tn-header mt">
            <el-form ref="form" label-width="160px" :rules="pushPaperrules">
                <section class="send-paper-require">

                        <label>答题时段</label>
                        <span>{{start.split(' ')[0]}} ～</span>
                        <el-date-picker
                                v-model="secondForm.fixedTime"
                                type="date"
                                clearable="false"
                                placeholder="选择截止日期"
                                @change="getTimeSlot"
                                :picker-options="pickerOptions">
                        </el-date-picker>


                        <div class="mt40">
                            <label>答题时长 </label>
                            <el-input class="mr20" value="120"
                                  placeholder="请输入时长"
                                  @keyup.enter="getLimitTime"
                                  v-model="CostTime" >
                            </el-input>分钟
                        </div>

                </section>

                <section class="training-noticebox mt">

                <section class="traniing-info-tab">
                    <span v-for="item,$index in tabList" :class="{'tab-active': tabIndex ==$index}" @click="tabActive($index)">{{item}}</span>
                </section>
                <div class="notice-middle" v-show="tabIndex==0">
                    <div class="last-notice">剩余可发短信：{{SmsBalance}}条</div>
                    <p>提示：为保障短信正常送达，请注意用词，勿发送营销类信息，{{noticeCostOne}}元/条</p>
                    <div><el-button class="recharge-btn" type="primary" @click="PayStepOne(1)">微信充值</el-button></div>
                </div>
                <div class="notice-main">
                    <div class="notice-middle" v-show="tabIndex==1">
                        <div class="last-notice">剩余可发邮件条数：{{SmsBalance}}条</div>
                        <p>提示：为保障短信正常送达，请注意用词，勿发送营销类信息，{{emailCostOne}}元/条</p>
                        <div><el-button class="recharge-btn" type="primary" @click="PayStepOne(2)">微信充值</el-button></div>
                    </div>

                    <el-form-item v-if="tabIndex==1" label="主题" class="pt30">
                        <el-input class="input" placeholder="请输入主题名称" v-model="subject"></el-input>
                    </el-form-item>
                    <!--<el-form-item v-if="tabIndex==1" label="抄送">-->
                        <!--<el-input class="input" placeholder="请输入邮箱，多个邮箱由英文间隔号隔开（选填）"></el-input>-->
                    <!--</el-form-item>-->
                    <el-form-item :label="tabIndex==0?'短信内容':'正文'">
                        <el-input type="textarea" :autosize="{ minRows:6}" v-model="noticeText"  placeholder="请输入正文内容"></el-input>
                        <!--<div class="name-box" style="height: 100px">{{noticeText}}</div>-->
                    </el-form-item>
                    <el-form-item label="学员明细">
                        <div class="name-box">

                            <template v-if="JoinType == 1">
                                <template v-if="!employeeTrainList.length">
                                    <section class="space-push-box">
                                        <section class="space-push">
                                            <!--<img src="http://jhsy-img.caizhu.com/sass/images/ic-Training-warning.png" alt="">-->
                                            <span>暂无待发放试卷学员</span> <!--未通知培训-->
                                        </section>
                                    </section>
                                </template>
                                <template v-if="employeeTrainList.length > 0">
                                    <ul class="child-list">
                                        <li v-for="item in employeeTrainList">
                                            <!--<span v-if="item.Aliasname.length > 0" :class="{'blue':item.isHasPhone == 0}">{{item.Aliasname}}</span>
                                            <span v-if="item.Aliasname.length == 0" :class="{'blue':item.isHasPhone == 0}">{{item.Username}}</span>-->
                                            <span v-if="item.Aliasname.length > 0">{{item.Aliasname}}</span>
                                            <span v-if="item.Aliasname.length == 0">{{item.Username}}</span>
                                        </li>
                                    </ul>
                                </template>

                            </template>
                            <template v-if="JoinType == 2">
                                <template v-if="!employeeList.length">
                                    <section class="space-push-box">
                                        <section class="space-push">
                                            <!--<img src="http://jhsy-img.caizhu.com/sass/images/ic-Training-warning.png" alt="">-->
                                            <span>暂无已报名学员</span>
                                           <!-- <span v-if="unStart == 0">报名未开始，暂无已报名学员</span>-->  <!--通知报名了，报名时间未到-->
                                           <!-- <span v-if="unStart == 1">报名已开始，暂无已报名学员，请培训结束后再发放考试</span>--> <!--通知报名了，报名时间已经开始，未有报名人员-->
                                        </section>
                                    </section>
                                </template>
                                <template v-if="employeeList.length > 0">
                                    <ul class="child-list">

                                        <!--<li>
                                            <span :class="{'blue':isHasPhone == 0}">雪饼</span>
                                            <img v-if="isHasPhone == 0" class="public-icon" src="http://jhsy-img.caizhu.com/sass/images/write_ic.png" alt="">
                                        </li>-->

                                        <li v-for="item in employeeList">
                                            <span v-if="item.Aliasname.length > 0" :class="{'blue':item.isHasPhone == 0}">{{item.Aliasname}}</span>
                                            <span v-if="item.Aliasname.length == 0" :class="{'blue':item.isHasPhone == 0}">{{item.Username}}</span>


                                            <!--<img v-if="item.isHasPhone == 0" @click="doAddPhone" class="public-icon edit-icon" src="http://jhsy-img.caizhu.com/sass/images/write_ic.png" alt="">-->

                                            <!--<el-dialog
                                                    :title="dialogAddPhone.title"
                                                    :visible.sync="dialogAddPhone.centerDialogVisible"
                                                    width="460px"
                                                    center>
                                                <label class="mr20" v-if="item.Aliasname.length > 0">{{item.Aliasname}}</label>
                                                <label class="mr20" v-if="item.Aliasname.length == 0">{{item.Username}}</label>
                                                <el-input v-model="dialogAddPhone.phoneNumber"  placeholder="请输入手机号码"></el-input>
                                                <span slot="footer" class="dialog-footer">
                            <el-button class="dialog-btn-left" @click="dialogAddPhone.centerDialogVisible = false">取 消</el-button>
                            <el-button class="dialog-btn-right" type="primary" @click="doSaveEdit">增 加</el-button>
                        </span>
                                            </el-dialog>-->

                                        </li>
                                    </ul>
                                </template>

                            </template>

                        </div>
                        <!--<p class="notice-tip"><span class="color-main">蓝色名字</span>无电话，需补全才能收到通知</p>-->
                    </el-form-item>
                    <el-form-item>
                        <el-button class="ml20 btn-active btn-or" @click="doNotice('form')">发放</el-button>
                    </el-form-item>

                </div>

                <el-dialog
                        :title="dialogLittle.title"
                        :visible.sync="dialogLittle.centerDialogVisible"
                        width="460px"
                        center>
                    <el-input class="input-dialog" v-if="sendType == 1" :placeholder="dialogLittle.noticePlaceholder" v-model="noticeNeedNum"></el-input>
                    <el-input class="input-dialog" v-if="sendType == 2" :placeholder="dialogLittle.emailPlaceholder" v-model="emailNeedNum"></el-input>
                    <p class="word-dialog-tap">支付方式：支付宝</p>
                    <p class="word-dialog-tap"  v-if="sendType == 1">收费标准：{{noticeCostOne}}元/条</p>
                    <p class="word-dialog-tap"  v-if="sendType == 2">收费标准：{{emailCostOne}}元/条</p>

                    <span slot="footer" class="dialog-footer">
                <el-button class="dialog-btn-left" @click="dialogLittle.centerDialogVisible = false">取 消</el-button>
                <el-button class="dialog-btn-right" type="primary" v-if="sendType == 1" @click="PayStepTwo(1)">增 加</el-button>
                      <el-button class="dialog-btn-right" type="primary" v-if="sendType == 2" @click="PayStepTwo(2)">增 加</el-button>
                        <!--<el-button class="dialog-btn-right" type="primary" @click="dialogLittle.centerDialogVisible = false">增 加</el-button>-->

            </span>
                </el-dialog>

                <el-dialog
                        :title="dialogTwo.title"
                        :visible.sync="dialogTwo.centerDialogVisible"
                        width="460px"
                        center>
                    <p class="word-dialog-tap"  v-if="sendType == 1">本次购买将消耗你{{noticeNeedPay}}元，用支付宝支付。</p>
                    <p class="word-dialog-tap"  v-if="sendType == 2">本次购买将消耗你{{emailNeedPay}}元，用支付宝支付。</p>
                    <span slot="footer" class="dialog-footer">
                <el-button class="dialog-btn-left" @click="dialogTwo.centerDialogVisible = false">取 消</el-button>
                <!--<el-button class="dialog-btn-right" type="primary" v-if="sendType == 1" @click="payStepThree(1)">确 认</el-button>
                <el-button class="dialog-btn-right" type="primary" v-if="sendType == 2" @click="payStepThree(2)">确 认</el-button>-->
                     <el-button class="dialog-btn-right" type="primary" v-if="sendType == 1" @click="account(1)">确 认</el-button>
                    <el-button class="dialog-btn-right" type="primary" v-if="sendType == 2" @click="account(2)">确 认</el-button>
            </span>
                </el-dialog>

                <el-dialog
                        :title="dialogThree.title"
                        :visible.sync="dialogThree.centerDialogVisible"
                        width="460px"
                        center>
                    <p class="word-dialog-tap">登录到支付宝支付</p>
                    <p class="word-dialog-tap">请在新开支付宝页面完成付款后选择：</p>

                    <span slot="footer" class="dialog-footer">
                <el-button class="dialog-btn-left" @click="dialogThree.centerDialogVisible = false">付款成功</el-button>
                <el-button class="dialog-btn-right" type="primary" @click="dialogThree.centerDialogVisible = false">付款失败</el-button>
            </span>
                </el-dialog>

            </section>
            </el-form>
        </section>

    </section>
</template>

<script>

	import qs from 'qs'
	import com from 'js/common'
	export default{
		data: function(){
			return {
				step:2,
                dataTime:'',
				tabIndex:0,
				// tabList:['短信通知','邮件通知'],

				dialogLittle:{
					centerDialogVisible: false,
					title:'充值',
					noticePlaceholder:'请输入所需短信条数',
					emailPlaceholder:'请输入所需邮件条数',
				},

				dialogTwo:{
					centerDialogVisible: false,
					title:'充值',
				},
				dialogThree:{
					centerDialogVisible: false,
					title:'充值',
				},


				success: '',


				sendType: 1,

				noticeText:'',

				isHasPhone: '',
                employeeTrainList:[],
				employeeList:[],

				ExamTitle:'',
				CostTime:'',


				dialogAddPhone:{
					title:'',
					centerDialogVisible: false,
					phoneNumber:'',
				},


				membersList :[],
                trainMemberList:[],
				noticeCostOne: 0.05,
				noticeNeedNum: '',
				noticeNeedPay:'',

				dialogTwo:{
					title:'',
					centerDialogVisible: false,
				},
				dialogThree:{
					title:'',
					centerDialogVisible: false,
				},


				SmsBalance:'',



				subject:'',
				emailCostOne: 0.05,
				emailNeedNum:'',
				emailNeedPay:'',
				EmailBalance: '',


				secondForm:{
					fixedTime:'',
				},
				allTime:'',
				start:'',
                end:'',

				pushPaperrules:{
					fixedTime: [
						{ required: true, message: '请选择答题时段', trigger: 'blur' },
					],

					CostTime: [
						{ required: true, message: '请输入答题时长', trigger: 'blur' },
					],

                },

				trainStart: false,

				JoinType:'',

				orderType: 3,
				buyNum: '',
				pay:'',

				pickerOptions: {
					disabledDate(time) {
						return time.getTime() < Date.now() - 8.64e7;
					}
				}

			}
		},
		mixins: [mixinMethods],
		methods: {
			toNotifyTrain(){
				let TrainID = this.$router.query.id;
			},


            getTestPaperDetail(){
				axios.post('/com/exam/getLib',qs.stringify({
                    trainID : ''
                })).then( (res) => {
                    var d = res.data;

                   if(d.flag == 1){

                    }else{
                   	    this.$message.error(d.msg);
                   }
                } );
            },

			tabActive(i){
				let self = this;
				self.tabIndex = i;
				self.sendType = i+1;
			},
			toNotifyTrain(){
				let TrainID = this.$route.query.TrainID;

			},
			getExamTitle(){
				let ExamID = this.$route.query.ExamID;
				/*let JoinType =  this.$route.query.JoinType;*/
				axios.post('/com/exam/get', qs.stringify({
					ExamID : ExamID,
				})).then( (res) => {
					var d = res.data;
					if(d.flag == 1){
					    var self = this;
                        this.ExamTitle = d.data.ExamTitle;
                        //以下用的开源的生成短连接API接口,线上网址suo.im
                        axios.post('/com/notice/shortUrl', qs.stringify({
                            url:'https://jhsy.jinghao.com/sass/test-detail?examID='+ExamID
                        })).then( (res) => {
                            var d = res.data;
                            if(d.flag == 1){
                                self.noticeText ='《'+ self.ExamTitle + '》，请在: '+ (self.start.split(' ')[0]==self.end.split(' ')[0]?self.start.split(' ')[0]:(self.start.split(' ')[0]+'至'+self.end.split(' ')[0])) +'完成考试，考试时长'+ self.CostTime +'分钟，点击链接考试：'+ d.data.url;
                            }else{
                                this.$message.error(d.msg);
                            }
                        });

					}else{
						this.$message.error(d.msg);
					}
				})
			},

			getEmployeeList(){
				let TrainID = this.$route.query.TrainID;
				axios.post('/com/train/getAllEnrollMembers', qs.stringify({
					TrainID: TrainID,
				})).then( (res) => {
					var d = res.data;

					if(d.flag == 1){
						if(d.data.length == 0){
							this.$message.error('报名已开始,暂无报名人员！');
                        }else{
							this.$message.success('报名已开始，有报名人员！');
							this.employeeList =d.data;

							console.log(this.employeeList);

							let arr= this.employeeList;
							var result = [];
							for (var i = 0; i < arr.length; i++) {
								var rObj = new Object();
								rObj["Mobile"] = arr[i].Mobile;
								rObj["EmployeeID"] = arr[i].EmployeeID;
								rObj["Email"] = arr[i].Email;
								result.push(rObj);
							}

							this.membersList = result;
                            console.log(this.membersList)
                        }

//   员工无号码情况下--
						/*this.employeeList.push({Aliasname: "usay",Mobile:"",Username:"李然"});  // 无号码员工--添加号码
                        this.employeeList.forEach(item=>{
                            item["isHasPhone"] = "0";
                            console.log(item);
                            console.log(item.employeeList);
                                if(item.Mobile.length == 0){
                                    item["isHasPhone"] = "0";
                                }else if(item.Mobile.length == undefined){
                                    item["isHasPhone"] = "0";
                                }else if(item.Mobile.length > 0){
                                    item["isHasPhone"] = "1";
                                }
                        });*/




					}else{
						this.$message.error(d.msg);
					}
				} );
			},

            getEmployeeTrainList(){
				let TrainID = this.$route.query.TrainID;
				axios.post('/com/train/getTrainMembers', qs.stringify({
					TrainID: TrainID,
                })).then( (res) => {
                    var d = res.data;
                    console.log(d.data);
					console.log(d);
                    if(d.flag == 1){
						if(d.data.length == 0){
							this.$message.error('通知培训时，未选择通知人员！');
						}else{
							this.employeeTrainList =d.data;

							let arr= this.employeeTrainList;
							var result = [];  // 新数组
							for (var i = 0; i < arr.length; i++) {
								var rObj = new Object();
								rObj["Mobile"] = arr[i].Mobile;
								rObj["EmployeeID"] = arr[i].EmployeeID;
								rObj["Email"] = arr[i].Email;
								result.push(rObj);
							}
							this.trainMemberList = result;
						}
                    }else{
                        this.$message.error(d.msg);
                    }
                } );

            },

			doAddPhone(){
				this.dialogAddPhone.centerDialogVisible =  true;
			},
			doSaveEdit(){

				this.dialogAddPhone.centerDialogVisible = false;
			},

			getMessageNum(){

				axios.post('/com/account/getSmsBalance', qs.stringify({

				})).then( (res) => {
					var d = res.data;
					if(d.flag == 1){
						this.SmsBalance = d.data.SmsBalance;
						if(this.SmsBalance > 0 ){
							this.$message.success('短信剩余余额为 '+this.SmsBalance+' ！');
						}else {
							this.$message.error('短信剩余余额为 0 ，请充值后在进行其他操作！');
                        }
					}else{
						this.$message.error(d.msg);
					}
				} );

			},


			getEmailNum(){

				axios.post('/com/account/getEmailBalance', qs.stringify({   // 参数错误？？

				})).then( (res) => {
					var d = res.data;
					if(d.flag == 1){

						this.EmailBalance = d.data.EmailBalance;

					}else{
						this.$message.error(d.msg);
					}
				} );
			},

			doNotice(){
				let self = this;
                if(this.trainStart == true){
					if(!this.secondForm.fixedTime){
						this.$message.error('请选择答题时段！');
					}else if(!this.CostTime){
                        this.$message.error('请输入答题时长！');
                    }else if(this.JoinType == 1){ /*培训参与*/
                        if(this.infoList.NotifyTrain == 0){
                            this.$message.error('暂无可发放人员！');
                        }else if(this.infoList.NotifyTrain == 1){ // 通知培训时未选择通知人员
                            if(this.employeeTrainList.length == 0){//
                                this.$message.error('未选择通知人员！');
                            }else{
                                this.$message.success('发放成功！');
                                this.goNotice();
                            }
                        }
                    }else if(this.JoinType == 2){
                        if(this.infoList.NotifyEnroll == 0){
                            this.$message.error('培训已开始，暂无已报名人员，不能发放试卷！');
                        }else if(this.infoList.NotifyEnroll == 1){   // 培训开始，已经通知报名
                            if(this.employeeList.length == 0){
                                this.$message.error('未选择通知人员！');
                            }else{
                                this.$message.success('发放成功！');
                                this.goNotice();
                            }
                        }
                    }

                }else{
					this.$message.error('培训未开始，不能发放试卷！');
                }

			},

            goNotice(){
				let TrainID = this.$route.query.TrainID;

				if(this.sendType == 1){  // 短信通知

					if(this.SmsBalance ==0){
						this.$message.error('请充值后再通知');

					}else if(this.SmsBalance > 0){

						if(this.JoinType == 2){
                            console.log(this.membersList);

							axios.post('/com/train/dispatchExam', qs.stringify({

								TrainID: TrainID,
								sendType: 1,
								body: this.noticeText,
								subject: this.subject,
								employees: this.membersList,
								costTime : this.CostTime,
								startTime: this.start,
								stopTime: this.secondForm.fixedTime ? com.dateFormat(this.secondForm.fixedTime,'yyyy-MM-dd 23:59:59') :'',

							})).then( (res) => {
								var d = res.data;
								if(d.flag == 1){
									this.$message.success('通知成功');
                                    location.assign('/training/training-manage');
								}else{
									this.$message.error(d.msg);
								}
							} );

						}else if(this.JoinType == 1){


							axios.post('/com/train/dispatchExam', qs.stringify({

								TrainID: TrainID,
								sendType: 1,
								body: this.noticeText,
								subject: this.subject,
								employees: this.trainMemberList,
								costTime : this.CostTime,
								startTime: this.start,
								stopTime: this.secondForm.fixedTime ? com.dateFormat(this.secondForm.fixedTime,'yyyy-MM-dd 23:59:59') :'',

							})).then( (res) => {
								var d = res.data;
								if(d.flag == 1){
									this.$message.success('通知成功');
                                    location.assign('/training/training-manage');
								}else{
									this.$message.error(d.msg);
								}
							} );

						}

					}

				}else if(this.sendType == 2){

					if(this.EmailBalance == 0){
						this.$message.error('请充值后再通知');
					}else if(this.EmailBalance > 0){
//
						this.$message.success('邮件剩余余额为'+this.EmailBalance+'！');
						if(this.JoinType == 2){

							axios.post('/com/train/dispatchExam', qs.stringify({

								TrainID: TrainID,
								sendType: 2,
								body: this.noticeText,
								subject: this.subject,
								employees: this.membersList,
								costTime : this.CostTime,
								startTime: this.start,
								stopTime: this.secondForm.fixedTime ? com.dateFormat(this.secondForm.fixedTime,'yyyy-MM-dd 23:59:59') :'',

							})).then( (res) => {
								var d = res.data;
								if(d.flag == 1){
									this.$message.success('通知成功');
                                    location.assign('/training/training-manage');
								}else{
									this.$message.error(d.msg);
								}
							} );

						}else if(this.JoinType == 1){

							axios.post('/com/train/dispatchExam', qs.stringify({

								TrainID: TrainID,
								sendType: 2,
								body: this.noticeText,
								subject: this.subject,
								employees: this.trainMemberList,
								costTime : this.CostTime,
								startTime: this.start,
								stopTime: this.secondForm.fixedTime ? com.dateFormat(this.secondForm.fixedTime,'yyyy-MM-dd 23:59:59') :'',

							})).then( (res) => {
								var d = res.data;
								if(d.flag == 1){
									this.$message.success('通知成功');
                                    location.assign('/training/training-manage');
								}else{
									this.$message.error(d.msg);
								}
							} );

						}

					}

				}
            },


			PayStepOne(a){
				if(a == 1){
					this.sendType = 1;
					this.dialogLittle.centerDialogVisible = true;

				}else if(a == 2){
					this.sendType = 2;
					this.dialogLittle.centerDialogVisible = true;

				}

			},

			getPayPrice(a){
				if(a==1){
					this.noticeNeedPay = this.noticeCostOne*this.noticeNeedNum;
//					console.log(this.noticeNeedPay);
				}else if(a == 2){
					this.emailNeedPay = this.emailCostOne*this.emailNeedNum;
//					console.log(this.emailNeedPay);
				}

			},

			PayStepTwo(t){
				if(t == 1){
					this.dialogLittle.centerDialogVisible = false;
					this.dialogTwo.centerDialogVisible = true;
					this.getPayPrice(t);

				}else if(t == 2){
					this.dialogLittle.centerDialogVisible = false;
					this.dialogTwo.centerDialogVisible = true;
					this.getPayPrice(t);
				}

			},
			payStepThree(t) {
				if (t == 1) {
					this.dialogTwo.centerDialogVisible = false;
					this.judgeSuccess();
					if(this.success == 0){
						alert('付款失败');
						this.dialogThree.centerDialogVisible = true;
					}else if(this.success == 1){
						alert('付款成功');
						this.dialogThree.centerDialogVisible = true;
					}

				} else if (t == 2) {
					this.dialogTwo.centerDialogVisible = false;
					this.judgeSuccess();
					if(this.success == 0){
						alert('付款失败');
						this.dialogThree.centerDialogVisible = true;
					}else if(this.success == 1){
						alert('付款成功');
						this.dialogThree.centerDialogVisible = true;
					}
				}
			},

			judgeSuccess(){
				return this.success;
			},

            getTrainCostTime(){
				let examID = this.$route.query.ExamID;
				axios.post('/com/exam/get', qs.stringify({

					examID: examID,

				})).then( (res) => {
					var d = res.data;
					if(d.flag == 1){
						/*this.$message.success('答题时长');*/
						this.CostTime = d.data.AllowCostTime;
						this.start = d.extra.time;
					}else{
						this.$message.error(d.msg);
					}
				} );
            },

            getLimitTime(){
                this.getTrainCostTime();
				let ExamID = this.$route.query.ExamID;

            },

			getBasicInfo(){
				let TrainID = this.$route.query.TrainID;
				axios.post('/com/train/get', qs.stringify({
					TrainID : TrainID,
				})).then( (res) => {
					var d = res.data;
					if(d.flag == 1){
						this.infoList = d.data;
						this.JoinType = this.infoList.JoinType;

						if(Date.parse(new Date(String(this.infoList.TrainTime))) <= new Date(String(this.start)) ){

							this.trainStart = true;
							if(this.JoinType == 1){ //通知参与
								if(this.infoList.NotifyTrain == 0){
									this.$message.error('暂无可发放人员！');
								}else if(this.infoList.NotifyTrain == 1&&d.data.NotifyExam==0){
									this.getEmployeeTrainList();
								}

							}else if(this.JoinType == 2&&d.data.NotifyExam==0){   //报名参与
//								if(Date.parse(new Date(String(this.infoList.EnrollStartTime)))>= new Date(String(this.start))){
//									this.unStart = 0;
//									this.$message.error('报名未开始，不能发放试卷！');
//								}else{
									this.unStart = 1;
									this.getEmployeeList();
//								}
							}
                        }else{
                            this.$message.error('培训未开始，不能发放试卷！');
                            this.trainStart = false;
                        }

					}else{
						this.$message.error(d.msg);
					}
				} )
			},

            getTimeSlot(){
                this.allTime = this.secondForm.fixedTime;
                this.end =  this.allTime ? com.dateFormat(this.secondForm.fixedTime,'yyyy-MM-dd') :'';

                this.getExamTitle();

            },




			account(t){
				if(t == 1){
					this.orderType = 3;
					this.buyNum = this.noticeNeedNum;
					this.pay = this.noticeNeedPay;
				}else if(t ==2){
					this.orderType = 4;
					this.buyNum = this.emailNeedNum;
					this.pay = this.emailNeedPay;
				}
				axios.post('/com/orders/addOther', qs.stringify({
					orderType:this.orderType,
					num:this.buyNum
				})).then((res) => {
					var d = res.data;
					if(d.flag == 1){
						this.$router.push({name:'resourceResourcePay',query:{OID:d.data.OrderID,allCount:Number(this.pay).toFixed(2)}})
					}else {
						this.$message.error(d.msg)
					}
				});
			},


		},
		mounted: function(){


			this.getMessageNum();
			this.getEmailNum();
//			this.getExamTitle();
            axios.post('/com/index/getServerTime', qs.stringify({
            })).then( (res) => {
                var d = res.data;
                if(d.flag == 1){
                    this.start = d.extra.time;
                    this.getBasicInfo();
                }else{
                    this.$message.error(d.msg);
                }
            });

            this.getTrainCostTime();
            this.getLimitTime();

		}
	}


</script>
